package io.wins.vertx.web;

public class WebApplicationException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private final int status;
    private ErrorEntity errorEntity;

    public WebApplicationException(final int status) {
        this(null, status);
    }

    public WebApplicationException(final int status, final ErrorEntity errorEntity) {
        this(null, status, errorEntity);
    }

    public WebApplicationException(final String message, final int status) {
        super("status [" + status + "]. " + (message != null ? message : ""));
        this.status = status;
    }

    public WebApplicationException(final String message, final int status, final ErrorEntity errorEntity) {
        super("status [" + status + "], code [" + errorEntity.code().toString() + "]. "
                + (message != null ? message : ""));
        this.status = status;
        this.errorEntity = errorEntity;
    }

    public int status() {
        return status;
    }

    public ErrorEntity errorEntity() {
        return errorEntity;
    }
}
